using Microsoft.AspNetCore.Mvc;
using RuoVea.GoFastdfs.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace RuoVea.GoFastdfs.Web.Controllers
{

    /**
     * @description 常用Controller,包含首页,登录,退出等
     * @author Perfree
     * @date 2021/3/22 13:44
     */
    public class LoginController : BaseController
    {
        private UserService _userService;
        public LoginController(UserService _userService) {
            _userService = _userService;
        }

        //private final static Logger LOGGER = LoggerFactory.getLogger(SystemController.class);


        /// <summary>
        /// 登录页
        /// </summary>
        /// <returns></returns>
        public IActionResult Login()
        {
            return View();
        }

        ///**
        // * @description 登录
        // * @param user  user
        // * @return com.perfree.common.ResponseBean
        // * @author Perfree
        // */
        //@RequestMapping("/doLogin")
        //@ResponseBody
        //public ResponseBean doLogin(User user)
        //{
        //    try
        //    {
        //        UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(user.getAccount(), user.getPassword(), false);
        //        Subject subject = SecurityUtils.getSubject();
        //        subject.login(usernamePasswordToken);
        //        LOGGER.info("{} >>>login", user.getAccount());
        //        return ResponseBean.success();
        //    }
        //    catch (IncorrectCredentialsException e)
        //    {
        //        LOGGER.info(user.getAccount() + e.getMessage());
        //        return ResponseBean.fail("密码错误");
        //    }
        //    catch (UnknownAccountException e)
        //    {
        //        LOGGER.info(user.getAccount() + e.getMessage());
        //        return ResponseBean.fail("用户不存在");
        //    }
        //    catch (Exception e)
        //    {
        //        LOGGER.info(user.getAccount() + e.getMessage());
        //        return ResponseBean.fail("系统异常");
        //    }
        //}

        ///**
        // * @description 退出登录
        // * @return java.lang.String
        // * @author Perfree
        // */
        //@RequestMapping("/logout")
        //public String logout()
        //{
        //    Subject subject = SecurityUtils.getSubject();
        //    User user = new User();
        //    BeanUtils.copyProperties(subject.getPrincipals().getPrimaryPrincipal(), user);
        //    LOGGER.info("{} >>>logout", user.getAccount());
        //    subject.logout();
        //    return "redirect:/login";
        //}
    }
}